package edu.zju.gis.dldsj.service.impl;

import edu.zju.gis.dldsj.dao.RoleMapper;
import edu.zju.gis.dldsj.entity.Role;
import edu.zju.gis.dldsj.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanlo yanlong_lee@qq.com
 * @version 1.0 2018/08/09
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public Role select(String pk) {
        return roleMapper.selectByPrimaryKey(pk);
    }

    @Override
    public int insert(Role role) {
        return roleMapper.insertSelective(role);
    }

    @Override
    public void update(Role role) {
        roleMapper.updateByPrimaryKeySelective(role);
    }

    @Override
    public void delete(String s) {
        roleMapper.deleteByPrimaryKey(s);
    }

    @Override
    public boolean isExist(String s) {
        return roleMapper.selectByPrimaryKey(s) != null;
    }

    @Override
    public List<Role> getByPage(int offset, int size) {
        return roleMapper.selectByPage(offset, size);
    }

    @Override
    public Role getByName(String name) {
        return roleMapper.selectByName(name);
    }
}
